<template>
  <div id="home"
       class="page flex-r">
    <div class="home-left">
      <div class="logo">
        <img src="../../assets/img/logo2.png">
      </div>
      <div class="page-el">
        <div @click="showPage(1)"
             :class="{activePage: shoPage===1}"><i class="iconfont icon-dash_board"
             style="marginRight:0.12rem;"></i>实时数据</div>
        <div @click="showPage(2)"
             :class="{activePage: shoPage===2}"><i class="iconfont icon-dash_board"
             style="marginRight:0.12rem;"></i>数据对比</div>
        <div @click="showPage(3)"
             :class="{activePage: shoPage===3}"><i class="iconfont icon-biaoge"
             style="marginRight:0.12rem;"></i>统计排序</div>
      </div>
    </div>
    <div class="home-right">
      <div class="header-nav flex-r">
        <div>
        </div>
        <a-popconfirm title="是否退出登录?"
                      ok-text="是"
                      cancel-text="否"
                      @confirm="confirm"
                      placement="rightBottom">
          <div style="cursor:pointer">
            <img src="../../assets/img/favicon-16x16.png">
            <span>{{username}}</span>
          </div>
        </a-popconfirm>
      </div>
      <div class="child-page">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      searchContent: '',
      shoPage: 1,
      username: ''
    }
  },
  methods: {
    confirm () {
      window.localStorage.clear()
      window.location.reload()
    },
    // 切换页面
    showPage (index) {
      if (this.shoPage !== index) {
        this.shoPage = index
        if (index === 1) {
          this.$router.push('/timeData')
        } else if (index === 2) {
          this.$router.push('/compareData')
        } else {
          this.$router.push('/sortData')
        }
      }
    }
  },
  created () {
    this.username = window.localStorage.getItem('account')
    var path = this.$route.path
    if (path.match('/timeData')) {
      this.shoPage = 1
    } else if (path.match('/compareData')) {
      this.shoPage = 2
    } else if (path.match('/sortData')) {
      this.shoPage = 3
    }
  }
}
</script>

<style lang="less" scoped>
#home {
  background: #dee4f1;
  .home-left {
    min-width: 100px;
    background: #405891;
    width: 2.08rem;
    height: 100%;
    .logo {
      height: 0.38rem;
      margin: 0.14rem 0.24rem;
      width: 1.28rem;
      img {
        height: 100%;
      }
    }
    .page-el {
      font-size: 0.14rem;
      margin-top: 0.4rem;
      div {
        padding: 0.09rem 0.16rem;
        margin: 0.04rem 0;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.6);
        font-weight: 400;
      }
      .activePage {
        background: #437ede;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .home-right {
    width: calc(100% - 2.08rem);
    // width: 17.12rem;
    min-width: 610px;
    height: 100%;
    .header-nav {
      background: #405891;
      height: 0.64rem;
      min-height: 30px;
      box-shadow: inset 0.04rem 0.04rem 0.04rem 0.02rem rgba(0, 0, 0, 0.05);
      padding: 0.16rem 0.32rem;
      justify-content: space-between;
      .header-search {
        width: 2.56rem;
        height: 0.32rem;
        min-height: 18px;
        min-width: 136px;
        border-radius: 0.16rem;
        background: #dee4f1;
        padding: 0 0.24rem;
        input {
          border: none;
          background: none;
          outline: none;
          color: black;
        }
        input::placeholder {
          color: #405891;
        }
      }
      img {
        width: 0.24rem;
        height: 0.24rem;
        border-radius: 0.12rem;
        margin-right: 0.08rem;
      }
    }
  }
}
.child-page {
  width: 100%;
  height: calc(100% - 0.64rem);
  //   overflow: auto;
  background-color: #dee4f1;
}
</style>
